﻿using System;
using System.Threading.Tasks;
using Loong.Dependency;
using Loong.Events.Bus.Handlers;

namespace Loong.Events.Bus
{
    public interface IEventBus : ISingletonDependency
    {
        IDisposable Register<TEventData, TEventHandler>()
            where TEventData : IEventData
            where TEventHandler : IAsyncEventHandler<TEventData>;

        IDisposable Register(Type eventType, Type eventHandlerType);

        void Unregister(Type eventType, Type eventHandlerType);

        Task TriggerAsync<TEventData>(TEventData eventData)
            where TEventData : IEventData;

        Task TriggerAsync<TEventData>(object eventSource, TEventData eventData)
            where TEventData : IEventData;

        Task TriggerAsync(Type eventType, IEventData eventData);

        Task TriggerAsync(Type eventType, object eventSource, IEventData eventData);
    }
}
